﻿using System;
using System.Collections.Generic;
using System.Data.SQLite;
using InformationSystem.Dao;
using InformationSystem.Entity;

namespace InformationSystem.Service
{
	/// <summary>
	/// Description of ModuleService.
	/// </summary>
	public class ModuleService:IService<Module>
	{
		ModuleDao mDao = new ModuleDao();
		
		public ModuleService()
		{
		}

		#region IService implementation

		public bool add(Module objct)
		{
			return mDao.add(objct);
		}

		public bool del(Module objct)
		{
			return mDao.del(objct);
		}

		public bool update(Module objct)
		{
			return mDao.update(objct);
		}

		public Module query(Module objct)
		{
			return mDao.query(objct);
		}
		
		public Module queryByName(String name)
		{
			return mDao.queryByName(name);
		}

		public List<Module> queryAll()
		{
			return mDao.queryAll();
		}

        public List<Module> queryNotSelected(int programmeId)
        {
            return mDao.queryNotSelected(programmeId);
        }

        public List<Module> querySelected(int programmeId)
        {
            return mDao.querySelected(programmeId);
        }

		#endregion
		
		
		public SQLiteDataAdapter getDisplayColumn()
		{
			String sql = "select id, name ,credit from t_module order by id asc";
			
			return mDao.getDisplayColumn(sql);
		}
		
		
		public bool addOrUpdate(Module objct)
		{
			if(objct.id > 0)
			{
				return update(objct);
			}
			
			return add(objct);
		}
	}
}
